﻿package protocol.poker;

import java.util.ArrayList;
import java.util.HashMap;

import org.jboss.netty.buffer.ChannelBuffer;

import protocol.Iprotocol;

import config.SystemDefine;

import model.poker.Poker;

public class Poker_protocol  implements Iprotocol {
	
	private ArrayList<Poker>	pokersList=new ArrayList<Poker>();
	
	private int					UserId;
	
	private int					Type		= SystemDefine.getInstance().getPokerID();
	
	// 抢地主的倍数
	private int					Time		= 0;
	private int					robleadId	= 0;
	
	// /操作类型(用于模块系统内部的)
	private int					operate;
	
	// 底牌
	private Boolean				isFloor		= false;
	
	public int getUserId() {
		return UserId;
	}
	
	public void setUserId(int userId) {
		UserId = userId;
	}
	
	public int getType() {
		return Type;
	}
	
	public void setType(int type) {
		Type = type;
	}
	
	public int getOperate() {
		return operate;
	}
	
	public void setOperate(int operate) {
		this.operate = operate;
	}
	
	public ArrayList<Poker> getPokersList() {
		return pokersList;
	}
	
	public void setPokersList(ArrayList<Poker> pokersList) {
		this.pokersList = pokersList;
	}
	
//	public HashMap getAllData() {
//		HashMap maps = new HashMap();
//		maps.put("Type", Type);
//		maps.put("operate", operate);
//		maps.put("pokersList", pokersListChangeMap());
//		maps.put("user_id", UserId);
//		return maps;
//	}
//	
	public byte[] write() {
		return null;
	}
	
	@Override
	public void read(ChannelBuffer buffer){
		
	}
	
	private ArrayList pokersListChangeMap() {
		ArrayList<HashMap> arrayList = new ArrayList<HashMap>();
		for (int i = 0; i < pokersList.size(); i++) {
			HashMap hashMap = new HashMap();
			hashMap.put("color", pokersList.get(i).getColor());
			hashMap.put("value", pokersList.get(i).getValue());
			arrayList.add(hashMap);
		}
		
		return arrayList;
	}
	
	

	public int getTime() {
		return Time;
	}
	
	public void setTime(int time) {
		Time = time;
	}
	
	public int getRobleadId() {
		return robleadId;
	}
	
	public void setRobleadId(int robleadId) {
		this.robleadId = robleadId;
	}
	
	public Boolean getIsFloor() {
		return isFloor;
	}
	
	public void setIsFloor(Boolean isFloor) {
		this.isFloor = isFloor;
	}
	
}
